LassoScript Utility
Basics Browse Detail

[File->Open]

Tag Link [File->Open] Category File
Type Member Source Available Yes
Support Preferred Version 7.0
Change Unchanged Data Source Any
Output Type None Security File
Implementation LCAPI Sets Lasso 8.5, Lasso 8.0, Lasso 7.0

Description

Opens a new connection to a file. Requires the name and path to a file as a parameter. Optional parameters may include an open mode and read mode, as in the [File] tag. The open mode and read mode set in the initial [File] tag call are used by default.

Syntax

[File Variable->(Open: '/folder/file.txt')]

Parameters

Required Parameters
'File path' The name and path to a file.
Optional Parameters
Open Mode The open mode defines the purpose and permissions of the file connection, and may be one of the following values:

  • File_OpenRead – Sets the file connection to read-only.

  • File_OpenWrite – Sets the file connection to write-only.

  • File_OpenReadWrite – Sets the file connection to read and write.

  • File_OpenWriteAppend – Sets the file connection to write and append data.

  • File_OpenWriteTruncate – Sets the file connection to write and truncate data.
  • Read Mode The read mode defines whether the file will be initially read by line or by character, and may be one of the following values:

  • File_ModeChar – Reads a file character by character.

  • File_ModeLine – Reads a character line by line.
  • Examples

    To open a new file:

    Use the [File->Open] tag. The following example closes the connection to the myfile.txt file, and opens a new connection to a file named otherfile.txt.

    [Var:'File'=(File: 'myfile.txt', File_OpenRead, File_ModeChar)]
    [$File->(Open: 'otherfile.txt', File_OpenReadWrite)]